package com.gy.smart.home.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.gy.smart.R;
import com.gy.smart.handle.bean.HandleThemeBean;
import com.nostra13.universalimageloader.core.ImageLoader;

import java.util.List;

/**
 * 作者：gy on 17/1/3
 * 说明：首页办事
 */
public class HomeHandleAdapter extends BaseAdapter {

    private Context context;
    private List<HandleThemeBean> list;

    public HomeHandleAdapter(Context context,List<HandleThemeBean> list){
        this.context = context;
        this.list = list;
    }

    @Override
    public int getCount() {
        return list.size() + 1;
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        convertView = View.inflate(context, R.layout.adapter_home_handle,null);
        ImageView img = (ImageView) convertView.findViewById(R.id.adapter_home_handle_img);
        TextView tvName = (TextView) convertView.findViewById(R.id.adapter_home_handle_tv);
        if(position < list.size()){
            ImageLoader.getInstance().displayImage(list.get(position).theme_img_url,img);
            tvName.setText(list.get(position).theme_name);
            tvName.setVisibility(View.VISIBLE);
        } else {
            img.setImageResource(R.mipmap.ic_home_handle_add);
            tvName.setVisibility(View.GONE);
        }
//        switch (position){
//            case 0:
//                img.setImageResource(R.mipmap.ic_handle_edu);
//                tvName.setText("教育");
//                break;
//            case 1:
//                img.setImageResource(R.mipmap.ic_handle_house);
//                tvName.setText("住房");
//                break;
//            case 2:
//                img.setImageResource(R.mipmap.ic_handle_ldjy);
//                tvName.setText("就业");
//                break;
//            case 3:
//                img.setImageResource(R.mipmap.ic_handle_shbx);
//                tvName.setText("社会保障");
//                break;
//            case 4:
//                img.setImageResource(R.mipmap.ic_handle_crj);
//                tvName.setText("出入境");
//                break;
//            case 5:
//                img.setImageResource(R.mipmap.ic_handle_ylws);
//                tvName.setText("医疗卫生");
//                break;
//            case 6:
//                img.setImageResource(R.mipmap.ic_handle_hysy);
//                tvName.setText("婚育收养");
//                break;
//            case 7:
//                img.setImageResource(R.mipmap.ic_home_handle_add);
//                tvName.setVisibility(View.GONE);
//                break;
//        }
        return convertView;
    }
}
